<template>
  <div style="margin-bottom: 10px">
    <div class="fac-name">
      <span style="font-size: 20px; font-weight: 700; color: #fff">{{ props.qyInfo.qymc }}</span>
      <div class="fac-right-btn">
        <img
          src="@/assets/image/common/edit-icon.png"
          title="编辑表单"
          @click="editClick(props.qyInfo.id)"
        />

        <!-- 地图要素上图 -->
        <img
          v-if="props.qyInfo.sfbh === 0"
          src="@/assets/image/common/map-add.png"
          title="点击开始标注"
          @click.stop="addMapQyClick(props.qyInfo)"
        />
        <!-- 地图要素删除 -->
        <img
          v-else
          src="@/assets/image/common/map-delete.png"
          title="点击删除标注"
          @click.stop="delMapQyClick(props.qyInfo)"
        />
      </div>
    </div>
    <div class="address">
      <el-icon :size="16" color="#fff"><MapLocation /></el-icon>
      <span style="color: #fff">{{ props.qyInfo.qydz }}</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { MapLocation } from '@element-plus/icons-vue'
import { featureClick, delMapFactorInfo } from '@/utils/common/index'

// 声明proshowEditFactoryps
const props = defineProps({
  qyInfo: {
    type: Object,
    default: () => {},
  },
})

const showEditFactory = inject('showEditFactory')

//点击编辑，查询企业信息
const editClick = (id) => {
  showEditFactory.value = true
}

/** 企业信息上图 */
const addMapQyClick = (qyInfo: any) => {
  qyInfo.mc = qyInfo.qymc
  featureClick({
    id: qyInfo.id,
    parentName: qyInfo.id,
    MapFactorType: 'scrollWall',
    MapFactorName: '企业',
    bzlx: '4',
    text: qyInfo.qymc,
    attribute: qyInfo,
  })
}

/** 删除企业信息地图要素 */
const delMapQyClick = (qyInfo: any) => {
  qyInfo.qyid = qyInfo.id
  delMapFactorInfo(qyInfo, 'scrollWall')
}
</script>

<style lang="less" scoped>
.fac-name {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fac-right-btn {
  display: flex;
  img:first-child {
    margin-right: 10px;
  }
  img {
    width: 30px;
    height: 30px;
    cursor: pointer;
  }
}
</style>
